/*
 * Trader Manager will handle message from Middleware and send back TCM after
 * price matching which we have not implemented.
 */

package ExchangeBusiness;

import XMLForms.TCM;
import XMLForms.WTRM;
import java.util.Date;
import org.w3c.dom.Document;

/**
 *
 * @author yuxia
 */
public class TradeManager {
    private final String acceptor = "WWSE";
    public TCM execute(WTRM request){
        //return a TCM xml file
        return createTCM(request);
    }

    private TCM createTCM(WTRM w){
        if (w.getTtrm().getStockID().equals("UBSH")){
            if (w.getTtrm().getOfferTime() == 7){
                return new TCM(w.getTtrm(), "WWSE", w.getFirmSeq()+1, 
                "Trade Completed", new Date().getTime());
            }
            return new TCM(w.getTtrm(), "WWSE2", w.getFirmSeq(), 
                "Trade Completed", new Date().getTime());
        }
        return new TCM(w.getTtrm(), acceptor, w.getFirmSeq(), 
                "Trade Completed", new Date().getTime());
    }
}
